﻿namespace TheSafety.Management
{
    using Agent;
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class ChangeItem : UserControl, IComponentConnector
    {
        private SynchronizationContext a;
        private EventHandler<RoutedEventArgs> b;
        internal Label c;
        internal Label d;
        internal Label e;
        internal Label f;
        internal Label g;
        internal Label h;
        internal Label i;
        internal Label j;
        internal Label k;
        internal Label l;
        internal Button m;
        internal Button n;
        internal Label o;
        internal ComboBox p;
        internal Label q;
        private bool r;
        [CompilerGenerated]
        private string s;
        [CompilerGenerated]
        private string t;

        public ChangeItem()
        {
            this.InitializeComponent();
            this.a();
        }

        private void a()
        {
            this.m.Content = e.c("Back");
            this.n.Content = e.c("ChangeSubscription");
            this.f.Content = e.c("Expires") + ":";
            this.c.Content = e.c("Subscribtion") + ":";
            this.e.Content = e.c("VPNUsername") + ":";
            this.i.Content = e.c("Cost") + ":";
            this.k.Content = e.c("Total") + ":";
            this.o.Content = e.c("Subscription") + ":";
            this.q.Content = e.c("YouCanChangeSubscription") + ":";
        }

        public void a(EventHandler<RoutedEventArgs> A_0)
        {
            EventHandler<RoutedEventArgs> handler2;
            EventHandler<RoutedEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<RoutedEventArgs> handler3 = (EventHandler<RoutedEventArgs>) Delegate.Remove(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<RoutedEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        private string a(DateTime A_0)
        {
            TimeSpan span = A_0.Subtract(DateTime.Now);
            return string.Concat(new object[] { span.Days, e.c("d"), " ", span.Hours, e.c("h"), " ", span.Minutes, e.c("m") });
        }

        [CompilerGenerated]
        private void a(object A_0)
        {
            SendOrPostCallback d = null;
            <>c__DisplayClass5 class2;
            string a = "";
            List<ManagementChangeInfoItem> b = new List<ManagementChangeInfoItem>();
            this.a.Send(new SendOrPostCallback(class2.e), null);
            if (!string.IsNullOrWhiteSpace(a))
            {
                MessageBox.Show(a);
            }
            else
            {
                if (d == null)
                {
                    d = new SendOrPostCallback(class2.d);
                }
                this.a.Send(d, null);
            }
        }

        private DateTime a(string A_0)
        {
            double result = 0.0;
            double.TryParse(A_0, out result);
            DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0);
            return time.AddSeconds(result);
        }

        [DebuggerNonUserCode, EditorBrowsable(EditorBrowsableState.Never)]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((ChangeItem) A_1).Loaded += new RoutedEventHandler(this.UserControl_Loaded);
                    return;

                case 2:
                    this.c = (Label) A_1;
                    return;

                case 3:
                    this.d = (Label) A_1;
                    return;

                case 4:
                    this.e = (Label) A_1;
                    return;

                case 5:
                    this.f = (Label) A_1;
                    return;

                case 6:
                    this.g = (Label) A_1;
                    return;

                case 7:
                    this.h = (Label) A_1;
                    return;

                case 8:
                    this.i = (Label) A_1;
                    return;

                case 9:
                    this.j = (Label) A_1;
                    return;

                case 10:
                    this.k = (Label) A_1;
                    return;

                case 11:
                    this.l = (Label) A_1;
                    return;

                case 12:
                    this.m = (Button) A_1;
                    this.m.Click += new RoutedEventHandler(this.btnBack_Click);
                    return;

                case 13:
                    this.n = (Button) A_1;
                    this.n.Click += new RoutedEventHandler(this.btnSubmit_Click);
                    return;

                case 14:
                    this.o = (Label) A_1;
                    return;

                case 15:
                    this.p = (ComboBox) A_1;
                    this.p.SelectionChanged += new SelectionChangedEventHandler(this.ddlPeriod_SelectionChanged);
                    return;

                case 0x10:
                    this.q = (Label) A_1;
                    return;
            }
            this.r = true;
        }

        public void b(EventHandler<RoutedEventArgs> A_0)
        {
            EventHandler<RoutedEventArgs> handler2;
            EventHandler<RoutedEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<RoutedEventArgs> handler3 = (EventHandler<RoutedEventArgs>) Delegate.Combine(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<RoutedEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        private void btnBack_Click(object A_0, RoutedEventArgs A_1)
        {
            if (this.b != null)
            {
                this.b(A_0, A_1);
            }
        }

        private void btnSubmit_Click(object A_0, RoutedEventArgs A_1)
        {
        }

        private void ddlPeriod_SelectionChanged(object A_0, SelectionChangedEventArgs A_1)
        {
            this.j.Content = ((this.p.SelectedItem as ComboBoxItem).Tag as ManagementChangeInfoItem).a();
            this.l.Content = this.a(((this.p.SelectedItem as ComboBoxItem).Tag as ManagementChangeInfoItem).d()).ToShortDateString();
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.r)
            {
                this.r = true;
                Uri resourceLocator = new Uri("/TheSafety;component/management/changeitem.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void UserControl_Loaded(object A_0, RoutedEventArgs A_1)
        {
            this.a = SynchronizationContext.Current;
            this.h.Content = this.a(this.c()).ToShortDateString() + " (" + this.a(this.a(this.c())) + ")";
            new Thread(new ParameterizedThreadStart(this.a)) { IsBackground = true }.Start(null);
        }

        public string PropDate
        {
            [CompilerGenerated]
            get
            {
                return this.s;
            }
            [CompilerGenerated]
            set
            {
                this.s = value;
            }
        }

        public string PropOrderID
        {
            [CompilerGenerated]
            get
            {
                return this.t;
            }
            [CompilerGenerated]
            set
            {
                this.t = value;
            }
        }

        public string PropSubscription
        {
            set
            {
                this.d.Content = value;
            }
        }

        public string PropUserName
        {
            set
            {
                this.g.Content = value;
            }
        }
    }
}

